//
//  KDJHttpTool.m
//  SleepNews
//
//  Created by Kavee DJ on 2016/12/8.
//  Copyright © 2016年 Kavee DJ. All rights reserved.
//

#import "KDJHttpTool.h"
#import "AFNetworking.h"

@implementation KDJHttpTool
SingleM(HttpTool)

- (void)runRequestWithParameters:(NSMutableDictionary *)parameters path:(NSString *)path success:(void (^)(id))success failure:(void (^)(id))failure {
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    [mgr GET:path parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        KLog(@" --%@ %@",path,responseObject);
        success(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        KLog(@" --%@ %@",path,error);
        failure(error);
    }];
}

@end
